from odoo import fields, models, api
from odoo.osv import expression


class ResUser(models.Model):
    _inherit = 'res.users'

    eng_name = fields.Char('English Name')

    def _change_uer_partner(self):
        for record in self:
            if record.partner_id:
                record.partner_id.company_type = 'person'
                record.partner_id.parent_id = self.env.company.partner_id.id

    def _name_search(self, name='', args=None, operator='ilike', limit=100, name_get_uid=None, order=None):
        args = args or []
        domain = ['|', ('name', operator, name), ('eng_name', operator, name)]
        return self._search(expression.AND([domain, args]), limit=limit, access_rights_uid=name_get_uid, order=order)

    def _compute_display_name(self):
        """Compute the display name for the user."""
        for user in self:
            if user.eng_name:
                user.display_name = f"{user.name}({user.eng_name})"
            else:
                user.display_name = user.name
